home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / progutil / stdwin.zoo / ABOUT next >
Encoding:
INI File  |  1989-10-17  |  15.5 KB  |  405 lines

  1. [Last modified on Sat Apr 15 20:19:00 MET DST 1989 by guido]
  2.  
  3.  
  4. 0. Copyright Notice
  5.  
  6. STDWIN is copyrighted: Copyright (c) 1988, 1989 by Stichting Mathematisch
  7. Centrum, Amsterdam, The Netherlands.  STDWIN is available for
  8. noncommercial use only, free of charge, and with no guarantees.  It can
  9. be freely used and distributed provided these restrictions are honoured.
  10.  
  11.  
  12. 1. Target systems
  13.  
  14. STDWIN is aimed at C programs.  It consists of a few header files (of
  15. which only one is visible to the user) and a library.  In most cases
  16. some system-provided libraries must also be used in the linking phase.
  17.  
  18. Currently, full STDWIN is available for the following environments:
  19.  
  20. (Note that in all cases the code is in beta test state; there may be
  21. bugs, functionality may change slightly in the future and new
  22. functionality may be added, but the basic framework isn't going to
  23. change much.)
  24.  
  25. *       X version 11, release 3 (should still work with release 2)
  26. *       Apple Macintosh, using either THINK C (3.01) or MPW C (2.02)
  27. *       Atari ST, using Mark Williams C (2.1)
  28.  
  29. You may volunteer to create a version for your favourite system, or to
  30. port it to your favourite C compiler for one of the mentioned micros.
  31. (The micro versions are rather compiler-dependent, due to the many
  32. differences between compilers and especially libraries.  Expect
  33. difficulties if you have another compiler or version than the ones
  34. mentioned.  Especially the Atari version is flakey.)
  35.  
  36. A subset, emulating most of STDWIN's functionality on an alphanumeric
  37. display (excluding line drawing, but including multiple (non-overlapping)
  38. windows, menus, text editing etc.) is available for:
  39.  
  40. *       Any decent Unix that has termcap (tested with 4.{2,3} BSD)
  41. *       MS-DOS, using the Microsoft C compiler (4.0)
  42.  
  43. Sorry, there are no versions yet for SunTools, SunView, NeWS, X10,
  44. MS-Windows, Presentation Manager or the Amiga.  A hacker might be able
  45. to turn the Atari ST version into a general GEM version.  The code is
  46. remarkably portable to different processor types and various Unix
  47. flavors, as long as they are derived from 4.xBSD.
  48.  
  49.  
  50. 2. Getting the full scoop
  51.  
  52. I have written a paper about STDWIN which has been published as a
  53. CWI report (Guido van Rossum: STDWIN -- A Standard Window System
  54. Interface.  Centre for Mathematics and Computer Science, report
  55. CS-R8817.  Amsterdam, 1988).
  56.  
  57. You can also get a source version for any or all of the above-mentioned
  58. systems.  This is essentially a directory dump of my working version,
  59. until I have the time or get some help to prepare a real distribution.
  60. It is available through anonymous ftp access from uunet.uu.net.
  61. The directory is amiga-sources/stdwin (thanks to the moderator, Peter
  62. da Silva) get the file README.txt for further instructions.  A version
  63. of this file is in ABOUT.txt.  (The version on gatekeeper no longer
  64. exists, although it may be revived in the near future).
  65.  
  66. Distribution to to non-ftp-users is solely by electronic mail.  Be
  67. prepared to receive up to half a megabyte (in 32K pieces in "shar"
  68. format).  If you're interested, write to guido@cwi.nl.
  69.  
  70.  
  71. 3. Basic functionality
  72.  
  73. STDWIN allows multiple "full-function" windows, roughly in Macintosh
  74. style (title bar, grow box, close box, scroll bars).  The appearance of
  75. windows is determined by the default of the underlying window manager,
  76. and so are other limitations (e.g., overlapping, maximum size, etc.).
  77. Windows are dynamically created and destroyed by the application, never
  78. directly by the user or the window manager.
  79.  
  80. STDWIN uses a coordinate system derived from the display's coordinate
  81. system: (0, 0) is top left, with X pointing right and Y pointing down
  82. (these are actually called h and v).  Pixel size is that of the display.
  83. There are enquiry functions to ask for the display size in pixels and in
  84. millimeters.
  85.  
  86. The application is responsible for redrawing the window contents when it
  87. is exposed.  This is done by associating a "draw procedure" with each
  88. window, which knows how to draw the entire window's contents.  It gets
  89. passed a pointer to the window and the coordinates of the rectangle that
  90. needs to be redrawn, so it can (although it needn't) restrict itself to
  91. that area.  STDWIN guarantees that a window's redraw procedure is only
  92. called while the application is waiting for an input event (most
  93. implementations simply turn exposure events into calls to the draw
  94. procedure).
  95.  
  96. If the application wants to change part of the graphics it is
  97. displaying, this is usually done in a two-phase process: first, STDWIN
  98. is told that a particular area of the screen must be changed; later,
  99. when the application starts waiting for input events again, the draw
  100. procedure is called to update the indicated area (and any other area
  101. that was exposed or damaged in some way).
  102.  
  103. The application defines the width and height of the area it wants to
  104. draw; this needn't bear any relation to the window or screen size.  This
  105. area is called the "document" although you may also think of it as a
  106. virtual window.  The actual window generally displays a sub-area of the
  107. document; the window's scroll bars indicate the position of the window
  108. with respect to the document.  The application always uses the
  109. coordinates of its document; STDWIN performs the translation to window
  110. or screen coordinates are required by the window manager, and ensures
  111. clipping of all output to the window.
  112.  
  113. STDWIN is event-based.  An application is expected to have a main loop
  114. containing a "get event" call followed by a switch on the event type.
  115. There is no event mask; an application can simply ignore events it isn't
  116. interested in.  The most important event types are:
  117.  
  118. ACTIVATE:       A window becomes active (keyboard attached and/or topmost)
  119.  
  120. CHAR:           ASCII character key pressed (except BS, TAB, CR)
  121.  
  122. COMMAND:        special key or function (CLOSE, TAB, RETURN, BS, CANCEL,
  123.                 arrow keys etc.)
  124.  
  125. MOUSE:          MOUSE DOWN, MOUSE MOVE (only while down), MOUSE UP;
  126.                 fields in the event record indicate the h, v position,
  127.                 the number of the button, and the "click number" if the
  128.                 event is potentially part of a multiple-click sequence
  129.  
  130. MENU:           menu id and item number of a menu selection
  131.  
  132. SIZE:           user has resized the window
  133.  
  134. TIMER:          the window's timer went off; each window has one
  135.                 programmable timer which can be set to go off at N/10
  136.                 seconds in the future.  When the timer goes off a TIMER
  137.                 event is returned.
  138.  
  139. Normally, STDWIN draws text in a single font.  The actual font used
  140. depends on the underlying window manager (and can sometimes be
  141. influenced by the application programmer and/or the end user in a
  142. system-dependent manner).  The font may be proportionally spaced, and
  143. there are enquiry functions to find out the dimensions of characters and
  144. strings.  There are also functions to change the font name and point
  145. size dynamically; but these work different in different systems,
  146. especially the allowed font names differ drastically.  This feature is
  147. used with some success in the ditroff previewer that is supplied as a
  148. demo.
  149.  
  150. There are functions to draw text and simple lines, rectangles and
  151. circles, and ways to erase, shade or invert rectangular areas.  There is
  152. no way (yet) to do general bitblt operations, or to influence the pen
  153. shape.
  154.  
  155.  
  156. 4. Higher level functionality
  157.  
  158. STDWIN provides a blinking vertical bar which can be used to indicate
  159. the text insertion point, so the application needn't use TIMER events to
  160. do the blinking.
  161.  
  162. STDWIN provides Macintosh-style menus.  Each window has its own set of
  163. menus, although by default all menus apply to all windows.  A reasonably
  164. number of menus per window is allowed, each with a reasonable number of
  165. (textual) menu items.  Menus can be changed dynamically.  Items can be
  166. enabled or disabled, and a 'tick mark' can be placed in front of an
  167. item.  Each menu item may have a shortcut character, which, when typed
  168. in combination with some system-defined meta key (e.g., ALT or an ESC-
  169. prefix) selects the menu item (if enabled).  Menu selection is done
  170. completely "underwater"; all the application notices are MENU events.
  171.  
  172. STDWIN has a few simple routines to display Mac-style "dialog boxes",
  173. e.g., to show an error message, or to ask a yes/no question or to ask
  174. for a string to be typed.  There is also a predefined function to ask
  175. for a file name, which may allow the user to browse the file system in
  176. some implementations.
  177.  
  178. STDWIN comes with a package built on top of the basic functionality, to
  179. edit arbitrary blocks of text (cf. Macintosh TEXTEDIT).  In the future,
  180. more packages will be provided, e.g., a package to provide a simple file
  181. editor (available now!), a package to display a scrolling list of items,
  182. a package to define a list of arbitrary labeled "buttons", and a package
  183. to simplify the binding of menus to functions somewhat, and a VT100
  184. emulator (available now!).
  185.  
  186.  
  187. 5. Function definitions
  188.  
  189. Here follows a slightly edited listing of the <stdwin.h> header file,
  190. which more or less documents all available functions and data
  191. structures.  Note that the argument lists are given here as ANSI C
  192. prototypes (untested).
  193.  
  194. #define bool int
  195.  
  196. void winit();
  197. void wdone();
  198.  
  199. void wsetdefwinsize(int width, int height);
  200. void wsetdefwinpos(int h, int v);
  201.  
  202. #define MENU struct menu
  203.  
  204. /* The contents of a text attributes struct are disclosed here because
  205.    the interface allows the programmer to declare objects of this type.
  206.    (I'm not so sure anymore that this is the right thing to do!) */
  207.  
  208. struct textattr {
  209.         short font;
  210.         unsigned char size;
  211.         unsigned char style;
  212. };
  213.  
  214. #define TEXTATTR struct textattr
  215.  
  216. #ifndef WINDOW
  217.  
  218. struct window {
  219.         short tag;
  220. };
  221.  
  222. #define WINDOW struct window
  223.  
  224. #endif
  225.  
  226. WINDOW *wopen(char *title, void drawproc();
  227. void wclose(WINDOW *win);
  228. #define wgettag(win) ((win)->tag)
  229. #define wsettag(win, newtag) ((win)->tag= newtag)
  230. void wsetactive(WINDOW *win);
  231. WINDOW *wgetactive();
  232. void wgetwinsize(WINDOW *win, int *width, int *height);
  233. void wsetdocsize(WINDOW *win, int width, int height);
  234. void wsettitle(WINDOW *win, char *title);
  235.  
  236. void wsetorigin(WINDOW *win, int h, int v);
  237. void wshow(WINDOW *win, int left, int top, int right, int bottom);
  238. void wchange(WINDOW *win, int left, int top, int right, int bottom);
  239. void wscroll(WINDOW *win, int left, int top, int right, int bottom,
  240.         int dh, int dv);
  241.  
  242. void wfleep();
  243. void wmessage(char *str);
  244. void wperror(char *name);
  245. bool waskstr(char *prompt, char *buf, int buflen);
  246. int waskync(char *question, int dflt);
  247. bool waskfile(char *prompt, char *buf, int buflen, bool new);
  248.  
  249. void wsetcaret(WINDOW *win, int h, int v);
  250. void wnocaret(WINDOW *win);
  251.  
  252. void wsettimer(WINDOW *win, int deciseconds);
  253.  
  254. MENU *wmenucreate(int id, char *title);
  255. void wmenudelete(MENU *mp);
  256. int wmenuadditem(MENU *mp, char *text, char shortcut);
  257. void wmenusetitem(MENU *mp, int i, char *text);
  258. void wmenusetdeflocal(bool local);
  259. void wmenuattach(WINDOW *win, MENU *mp);
  260. void wmenudetach(WINDOW *win, MENU *mp);
  261.  
  262. /* EVENT STRUCT DEFINITION */
  263.  
  264. struct event {
  265.         int type;
  266.         WINDOW *window;
  267.         union {
  268.         /* case WE_CHAR: */
  269.                 int character;
  270.         /* case WE_COMMAND: */
  271.                 int command;
  272.         /* case WE_MENU: */
  273.                 struct { int id; int item; } m;
  274.         /* case WE_DRAW: */
  275.                 struct { int left, top, right, bottom; } area;
  276.         /* case WE_MOUSE_DOWN, WE_MOUSE_MOVE, WE_MOUSE_UP: */
  277.                 struct {
  278.                         int v;
  279.                         int h;
  280.                         int clicks;
  281.                         int button;
  282.                         int mask;
  283.                 } where;
  284.         } u;
  285. };
  286.  
  287. #define EVENT struct event
  288.  
  289. /* Event types */
  290.  
  291. #define WE_NULL         0       /* (Used internally) */
  292. #define WE_ACTIVATE     1       /* Window became active */
  293. #define WE_CHAR         2       /* Character typed at keyboard */
  294. #define WE_COMMAND      3       /* Special command, function key etc. */
  295. #define WE_MOUSE_DOWN   4       /* Mouse button pressed */
  296. #define WE_MOUSE_MOVE   5       /* Mouse moved with button down */
  297. #define WE_MOUSE_UP     6       /* Mouse button released */
  298. #define WE_MENU         7       /* Menu item selected */
  299. #define WE_SIZE         8       /* Window size changed */
  300. #define WE_MOVE         9       /* (Reserved) */
  301. #define WE_DRAW         10      /* Request to redraw part of window */
  302. #define WE_TIMER        11      /* Window's timer went off */
  303. #define WE_DEACTIVATE   12      /* Window became inactive */
  304.  
  305. /* Command codes for WE_COMMAND.
  306.    Special ways of entering these are usually available,
  307.    such as clicking icons, standard menu items or special keys.
  308.    Some ASCII keys are also passed back as commands since they
  309.    more often than not need special processing. */
  310.  
  311. #define WC_CLOSE        1       /* Should become a separate event! */
  312. /* The following four are arrow keys */
  313. #define WC_LEFT         2
  314. #define WC_RIGHT        3
  315. #define WC_UP           4
  316. #define WC_DOWN         5
  317. /* ASCII keys */
  318. #define WC_CANCEL       6
  319. #define WC_BACKSPACE    7
  320. #define WC_TAB          8
  321. #define WC_RETURN       9
  322.  
  323. void wgetevent(EVENT *ep);
  324. void wungetevent(EVENT *ep);
  325. void wupdate(WINDOW *win);
  326. void wbegindrawing(WINDOW *win);
  327. void wenddrawing(WINDOW *win);
  328. void wflush();
  329.  
  330. void wdrawline(int h1, int v1, int h2, int v2);
  331. void wxorline(int h1, int v1, int h2, int v2);
  332. void wdrawcircle(int h, int v, int radius);
  333. void wdrawelarc(int h, int v, int radh, int radv, int angle1, int angle2);
  334. void wdrawbox(int left, int top, int right, int bottom);
  335. void werase(int left, int top, int right, int bottom);
  336. void wpaint(int left, int top, int right, int bottom);
  337. void winvert(int left, int top, int right, int bottom);
  338. void wshade(int left, int top, int right, int bottom, int percent);
  339.  
  340. int wdrawtext(int h, int v, char *str, int len);
  341. int wdrawchar(int h, int v, char c);
  342. int wlineheight();
  343. int wtextwidth(char *str, int len);
  344. int wcharwidth(char c);
  345. int wtextbreak(char *str, int len, int width);
  346.  
  347. void wgettextattr(TEXTATTR *attr);
  348. void wsettextattr(TEXTATTR *attr);
  349. void wgetwintextattr(WINDOW *win, TEXTATTR *attr);
  350. void wsetwintextattr(WINDOW *win, TEXTATTR *attr);
  351.  
  352. void wsetplain();
  353. void wsethilite();
  354. void wsetinverse();
  355. void wsetitalic();
  356. void wsetbold();
  357. void wsetbolditalic();
  358. void wsetunderline();
  359.  
  360. /* TEXTEDIT PACKAGE DEFINITIONS */
  361.  
  362. #define TEXTEDIT struct _textedit
  363.  
  364. TEXTEDIT *tealloc(WINDOW *win, int left, int top, int width);
  365. TEXTEDIT *tecreate(WINDOW *win,
  366.         int left, int top, int right, int bottom);
  367. void tefree(TEXTEDIT *tp);
  368. void tedestroy(TEXTEDIT *tp);
  369.  
  370. void tedraw(TEXTEDIT *tp);
  371. void tedrawnew(TEXTEDIT *tp, int left, int top, int right, int bottom);
  372. void temove(TEXTEDIT *tp, int left, int top, int width);
  373. void temovenew(TEXTEDIT *tp,
  374.         int left, int top, int right, int bottom);
  375.  
  376. void tesetfocus(TEXTEDIT *tp, int foc1, int foc2);
  377. void tereplace(TEXTEDIT *tp, char *str);
  378. void tesetbuf(TEXTEDIT *tp, char *buf, int buflen);
  379.  
  380. void tearrow(TEXTEDIT *tp, int code);
  381. void tebackspace(TEXTEDIT *tp);
  382. bool teclicknew(TEXTEDIT *tp, int h, int v, bool extend);
  383. bool tedoubleclick(TEXTEDIT *tp, int h, int v);
  384. bool teevent(TEXTEDIT *tp, EVENT *ep);
  385.  
  386. #define teclick(tp, h, v) teclicknew(tp, h, v, FALSE)
  387. #define teclickextend(tp, h, v) teclicknew(tp, h, v, TRUE)
  388.  
  389. char *tegettext(TEXTEDIT *tp);
  390. int tegetlen(TEXTEDIT *tp);
  391. int tegetnlines(TEXTEDIT *tp);
  392. int tegetfoc1(TEXTEDIT *tp);
  393. int tegetfoc2(TEXTEDIT *tp);
  394. int tegetleft(TEXTEDIT *tp);
  395. int tegettop(TEXTEDIT *tp);
  396. int tegetright(TEXTEDIT *tp);
  397. int tegetbottom(TEXTEDIT *tp);
  398.  
  399. /* Text paragraph drawing functions: */
  400.  
  401. int wdrawpar(int h, int v, char *text, int width);
  402.         /* Returns new v coord. */
  403. int wparheight(char *text, int width);
  404.         /* Returns height */
  405.